package edu.school.controller;

import edu.school.utils.ImgUtils;
import edu.school.utils.R;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.UUID;

/**
 * @author kabuda
 * @create 2023-09-30 11:36
 */
@RequestMapping("/utils")
@RestController
public class UtilsController {

        @RequestMapping(value="/upload",method=RequestMethod.POST)
        public R upload(@RequestParam("file") MultipartFile file) {
            String src = ImgUtils.upload(file);
            HashMap<String, Object> map = new HashMap<>();
            map.put("src",src);
            return R.data(map);
        }
}
